<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no" />
        <!--<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />-->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="css/website.css" />
        <title>Ajax Example</title>
    </head>
    <body>
    	<div id="main" data-role="page"> 
	        <div>
	            <h3>Phonegap Ajax Example</h3>
	            <div>
	            	<div class="ui-grid-b">
						<label for="ip_address">IP address:</label><input type="text" name="ip_address" id="ip_address">
						<label for="demoName" id="demo">DemoName = </label><input type="text" name="demoName" id="demoName">
						<div class="ui-block-a"><a id="onclickBtn" data-role="button" data-theme="b"  data-mini="true">submit_success</a></div>
					</div>
	            </div>	            
	        </div>
        </div> 
        <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
        <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
        <script type="text/javascript" charset="utf-8" src="js/jquery.mobile-1.2.0.min.js"></script>
        <script type="text/javascript">
			(function(){
					$('#main').live('pageshow',function(){
						
						$('#onclickBtn').bind('click',function(){
							var demoName = $('#demoName').val();
							var ipaddress = $('#ip_address').val();
							/* alert(demoName+" "+ipaddress );*/
							$.ajax(
							{
								"type" : "GET",
								"dataType" : "json",
								"url" : "http://"+ipaddress+":8080/cordovaServerDemo/servlet/demoServlet" ,
								"data" : "demoName="+demoName,
								"complete" : function(){}
								"success" : function(msg){//msg为返回的数据，在这里做数据绑定
									alert(msg.demoValue);
								}
							}
							);
						});
					});
				}
			)();
		</script>
    </body>
</html>
